<h1 id="完整配置"> 完整配置</h1>
<p>如上一章hello world的例子所示，<code>plugin.json</code>文件可以让你的插件与uTools无缝的结合在一起，下面我们列出了所有可能的配置项及注释供你参考：</p>
<div class="language-json extra-class">
    <pre class="language-json"><code><span class="token punctuation">{</span>
    <span class="token property">"pluginName"</span><span class="token operator">:</span> <span class="token string">"插件名称"</span><span class="token punctuation">,</span>
    <span class="token property">"version"</span><span class="token operator">:</span> <span class="token string">"0.0.1"</span><span class="token punctuation">,</span>
    <span class="token property">"description"</span><span class="token operator">:</span> <span class="token string">"插件描述"</span><span class="token punctuation">,</span>
    // 在uTools对应的位置显示
    <span class="token property">"author"</span><span class="token operator">:</span> <span class="token string">"开发者"</span><span class="token punctuation">,</span>
    // 如果配置了此项，用户点击`开发者`时，将在浏览器中打开此页面
    <span class="token property">"homepage"</span><span class="token operator">:</span> <span class="token string">"https://u.tools"</span><span class="token punctuation">,</span>
    // 入口文件，为空表示模板插件
    <span class="token property">"main"</span><span class="token operator">:</span> <span class="token string">"index.html"</span><span class="token punctuation">,</span>
    // 这是一个关键文件，你可以在此文件内调用uTools 、nodejs、electron提供的api
    <span class="token property">"preload"</span><span class="token operator">:</span><span class="token string">"preload.js"</span><span class="token punctuation">,</span>
    // 此插件的图标，这是必须存在的，否则打包后将无法安装
    <span class="token property">"logo"</span><span class="token operator">:</span> <span class="token string">"logo.png"</span><span class="token punctuation">,</span>
    // 插件支持的平台（默认为全平台支持）
    <span class="token property">"platform"</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">"win32"</span><span class="token punctuation">,</span> <span class="token string">"darwin"</span><span class="token punctuation">,</span> <span class="token string">"linux"</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
    // 在开发模式下，可使用development配置替换 main、preload、logo 的值，在打包时，此字段会被删除
    <span class="token property">"development"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
        <span class="token property">"main"</span><span class="token operator">:</span> <span class="token string">""</span><span class="token punctuation">,</span>
        <span class="token property">"preload"</span><span class="token operator">:</span> <span class="token string">""</span><span class="token punctuation">,</span>
        <span class="token property">"logo"</span><span class="token operator">:</span> <span class="token string">""</span><span class="token punctuation">,</span>
        // 可单独指定打包目录（默认为plugin.json所在目录）
        <span class="token property">"buildPath"</span><span class="token operator">:</span> <span class="token string">""</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    // 插件设置 (可选<span class="token punctuation">)</span>
    <span class="token property">"pluginSetting"</span><span class="token operator">:</span><span class="token punctuation">{</span>
        // 插件是否允许多开(默认不允许<span class="token punctuation">)</span>，多开方式：分离插件后，再次创建
        <span class="token property">"single"</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
        // 插件高度(可动态修改<span class="token punctuation">,</span>但用户不能调整高度<span class="token punctuation">)</span>
        <span class="token property">"height"</span><span class="token operator">:</span> <span class="token number">0</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    /*
     * features 描述了当uTools主输入框内容产生变化时，此插件是否显示在搜索列表中
     * 一个插件可以有多个功能，一个功能可以提供多个命令供用户搜索
     */ 
    <span class="token property">"features"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
        <span class="token punctuation">{</span>
        	// 插件提供的某个功能(必须<span class="token punctuation">)</span>
            <span class="token property">"code"</span><span class="token operator">:</span> <span class="token string">"uuid"</span><span class="token punctuation">,</span> 
            // 对此功能的说明，在搜索列表中出现
            <span class="token property">"explain"</span><span class="token operator">:</span> <span class="token string">"随机唯一值"</span><span class="token punctuation">,</span>
            // 功能图标<span class="token punctuation">,</span> 相对路径 支持png、jpg、svg (可选<span class="token punctuation">)</span>
            <span class="token property">"icon"</span><span class="token operator">:</span> <span class="token string">"res/xxxx.png"</span><span class="token punctuation">,</span>
            // 功能适配平台 <span class="token punctuation">[</span><span class="token string">"win32"</span><span class="token punctuation">,</span> <span class="token string">"darwin"</span><span class="token punctuation">,</span> <span class="token string">"linux"</span><span class="token punctuation">]</span> (可选<span class="token punctuation">)</span>
            <span class="token property">"platform"</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">"win32"</span><span class="token punctuation">,</span> <span class="token string">"darwin"</span><span class="token punctuation">,</span> <span class="token string">"linux"</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
            <span class="token property">"cmds"</span><span class="token operator">:</span><span class="token punctuation">[</span>
              // cmds 可以是简单的字符串<span class="token punctuation">,</span> 搜索进入
              <span class="token string">"uTools"</span><span class="token punctuation">,</span> <span class="token string">"中文"</span><span class="token punctuation">,</span>
              
              // cmds 也可以是一个对象，匹配场景，通过匹配过滤
              <span class="token punctuation">{</span>
                 // 类型，可能的值（img<span class="token punctuation">,</span> files<span class="token punctuation">,</span> regex<span class="token punctuation">,</span> over）
                 <span class="token property">"type"</span><span class="token operator">:</span> <span class="token string">"img"</span><span class="token punctuation">,</span>
                 // 文字说明，在搜索列表中出现（必须）
                 <span class="token property">"label"</span><span class="token operator">:</span> <span class="token string">"图片匹配"</span>
              <span class="token punctuation">}</span><span class="token punctuation">,</span>
              
              // files 实例
              <span class="token punctuation">{</span>
                <span class="token property">"type"</span><span class="token operator">:</span> <span class="token string">"files"</span><span class="token punctuation">,</span>
                <span class="token property">"label"</span><span class="token operator">:</span> <span class="token string">"文件匹配"</span><span class="token punctuation">,</span>
                // 支持file或directory (可选<span class="token punctuation">)</span>
                <span class="token property">"fileType"</span><span class="token operator">:</span> <span class="token string">"file"</span><span class="token punctuation">,</span>
                // 文件名称正则匹配  (可选<span class="token punctuation">)</span>
                <span class="token property">"match"</span><span class="token operator">:</span> <span class="token string">"/xxx/"</span><span class="token punctuation">,</span>
                // 数量限制（不少于） (可选<span class="token punctuation">)</span>
                <span class="token property">"minNum"</span><span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
                // 数量限制（不多于） (可选<span class="token punctuation">)</span>
                <span class="token property">"maxNum"</span><span class="token operator">:</span> <span class="token number">1</span>
              <span class="token punctuation">}</span><span class="token punctuation">,</span>
              
              // regex 实例
              <span class="token punctuation">{</span>
                <span class="token property">"type"</span><span class="token operator">:</span> <span class="token string">"regex"</span><span class="token punctuation">,</span>
                <span class="token property">"label"</span><span class="token operator">:</span> <span class="token string">"文本正则匹配"</span><span class="token punctuation">,</span>
                // 正则表达式字符串
                <span class="token property">"match"</span><span class="token operator">:</span><span class="token string">"/xxx/i"</span><span class="token punctuation">,</span>
                // 长度限制（主输入框中的字符不少于） (可选<span class="token punctuation">)</span>
                <span class="token property">"minLength"</span><span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
                // 长度限制（不多于） (可选<span class="token punctuation">)</span>
                <span class="token property">"maxLength"</span><span class="token operator">:</span> <span class="token number">1</span>
            <span class="token punctuation">}</span><span class="token punctuation">,</span>
            
            // over 实例(当uTools主输入框中的关键字无任何匹配项时出现<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                <span class="token property">"type"</span><span class="token operator">:</span> <span class="token string">"over"</span><span class="token punctuation">,</span>
                <span class="token property">"label"</span><span class="token operator">:</span> <span class="token string">"无匹配时"</span><span class="token punctuation">,</span>
                // 排除的正则 (可选<span class="token punctuation">)</span>
                <span class="token property">"exclude"</span><span class="token operator">:</span><span class="token string">"/xxx/i"</span><span class="token punctuation">,</span>
                // 长度限制（主输入框中的字符不少于） (可选<span class="token punctuation">)</span>
                <span class="token property">"minLength"</span><span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
                // 长度限制（不多于） (可选<span class="token punctuation">)</span>
                <span class="token property">"maxLength"</span><span class="token operator">:</span> <span class="token number">1</span>
            <span class="token punctuation">}</span><span class="token punctuation">,</span>
            
            // window 实例(根据呼出uTools前的活动窗口匹配<span class="token punctuation">)</span> 
            // ps<span class="token operator">:</span> 可使用uTools`窗口信息`关键字查看窗口信息 
            <span class="token punctuation">{</span>
                <span class="token property">"type"</span><span class="token operator">:</span> <span class="token string">"window"</span><span class="token punctuation">,</span>
                <span class="token property">"label"</span><span class="token operator">:</span> <span class="token string">"窗口动作"</span><span class="token punctuation">,</span>
                <span class="token property">"match"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
                   // 应用
                   <span class="token property">"app"</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">"xxx.app"</span><span class="token punctuation">,</span> <span class="token string">"xxx.exe"</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
                   // 匹配窗口标题的正则 (可选<span class="token punctuation">)</span>
                   <span class="token property">"title"</span><span class="token operator">:</span> <span class="token string">"/xxxx/"</span><span class="token punctuation">,</span>
                   // 窗口类  Windows专有 (可选<span class="token punctuation">)</span>
                   <span class="token property">"class"</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">"xxx"</span><span class="token punctuation">]</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span>
          <span class="token punctuation">]</span> 
       <span class="token punctuation">}</span>
    <span class="token punctuation">]</span>
<span class="token punctuation">}</span>
</code></pre>
</div>